const Mock = require('mockjs')

const data = Mock.mock({
  'items|30': [{ // items|30 生成30个这样的数
    id: '@id',
    title: '@sentence(10, 20)',
    'status|1': ['published', 'draft', 'deleted'],
    author: 'voidwx',
    display_time: '@datetime',
    pageviews: '@integer(300, 5000)' // 生成300-5000之间的随机数
  }]
})

const authData = Mock.mock({
  'items|40': [{
    id: '@id',
    userName: '@word(6,16)',
    'bioType|1': ['指纹识别', '人脸识别'],
    'softBioType|1': ['体重', '身高', '体重，身高', '无'],
    status: 'success',
    requestNetwork: '@ip',
    requestTime: '@datetime',
    duringTime: '@natural(1,5)'
  }]
})

const userServiceAuthData = Mock.mock({
  'items|30': [{
    id: '@id',
    userName: '@cname',
    'status|1': ['认证成功', '认证失败'],
    display_time: '@datetime',
    networkAddress: '@ip'
  }]
})

module.exports = [
  {
    url: '/yunwu-demo/table/list',
    type: 'get',
    response: config => {
      const items = data.items
      return {
        code: 20000,
        data: {
          total: items.length,
          items: items
        }
      }
    }
  },
  {
    url: '/yunwu-demo/userServiceData/authData/list',
    type: 'get',
    response: config => {
      const items = userServiceAuthData.items
      return {
        code: 20000,
        data: {
          total: items.length,
          items: items
        }
      }
    }
  },
  {
    url: '/yunwu-demo/bioAuthData/authData/list',
    type: 'get',
    response: config => {
      const items = authData.items
      return {
        code: 20000,
        data: {
          total: items.length,
          items: items
        }
      }
    }
  }
]
